

#include "includes.h"


int
get_type(void *a)
{
  if (MASK(a) == TAG_INT)
    {
      return TYPE_FIXNUM;
    }
  
  if (MASK(a) == TAG_PTR)
    {
      return OBJ_HDR(REMOVE_TAG(a))->type; 
    }

  if (MASK(a) == TAG_IMM)
    {
      return IMM_TYPE(a);
    }

  return TYPE_NONE;
}


yjk_obj_header *
to_float(yjk_obj_header *src)
{
  if (MASK(src) == TAG_INT)
    {
      yjk_obj_header *o = heap_alloc(sizeof(double), TYPE_FLOAT, task_ptr);
      *(double *) o->data = (double) ((int) src >> 2);
      return o;
    }

  if (MASK(src) == TAG_PTR) //heap object
    {
      src = (void *) src - 1; //remove tag

      switch(src->type)
	{
	case TYPE_FLOAT:
	  return src;

	default:
	  break;
	}
    }
  
  printf("Can't convert to float.\n");
  exit(1);
  return 0x0;
}



